<html>
<head>
    <meta charset="utf-8">
    <title>首页 - 数媒贴吧</title>
    <link rel="stylesheet" href="/statics/css/index.css">
    <link rel="stylesheet" href="/statics/css/common.css">
</head>
<body>
<?php require_once './Views/common/header.tpl.php';?>
<div class="box">
    <div class="left">
        <div class="post-list">
            <?php foreach($postLists as $val):?>
            <div class="post-item">
                <div class="post-title"><span class="cate">【<?php echo $val['c_title'];?>】</span>
                    <a href="/index.php?c=post&a=detail&post_id=<?php echo $val['id'];?>"><?php echo $val['p_title'];?></a>
                </div>
                <div class="post-content"><?php echo $val['content'];?></div>
                <div class="post-info">
                    <a href="javascript:evaluate(1, <?php echo $val['id'];?>);">赞(<?php echo $val['praise_count'];?>)</a>
                    <a href="javascript:evaluate(2, <?php echo $val['id'];?>);">踩(<?php echo $val['step_count']?>)</a>
                    <span><?php echo $val['username'];?> 发布于 <?php echo $val['created_at'];?></span>
                </div>
            </div>
            <?php endforeach;?>
        </div>
        <div class="page">
            <?php echo $pageHtml;?>
        </div>
    </div>
    <?php require_once './Views/common/right.tpl.php';?>
</div>
<div class="clear"></div>
<?php require_once './Views/common/footer.tpl.php';?>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    function evaluate(type, post_id) {
        var params = {
            type: type,
            post_id: post_id
        };
        jQuery.post('/index.php?c=post&a=evaluate', params, function(data) {
            if (data.status == 200) {
                alert('操作成功');
                window.location.reload();
            } else {
                alert(data.message);
            }
        }, 'json');
    }
</script>
</body>
</html>